### Inventory for student{{ item }} ###

[control_nodes:vars]
ansible_port=22
ansible_ssh_user=ec2-user
ansible_ssh_private_key_file="{{ playbook_dir }}/{{ ec2_name_prefix }}/{{ ec2_name_prefix }}-private.pem"

[student{{ item }}]
{% for host in hostvars %}
{%   if "student" + item + "-" in host -%}
{%     if "windc" in host -%}
{%     elif "gitlab" in host -%}
{%     elif "docs" in host -%}
{%     elif "rhel" in host -%}
{%     elif "ansible" in host %}
{%     elif "automationhub" in host %}
{{ host|replace(ec2_name_prefix + "-", "") }} ansible_host={{ hostvars[host].ansible_host }}
{%     else %}
{{ host|replace(ec2_name_prefix + "-", "") }} ansible_host={{ hostvars[host].ansible_host }} ansible_user={{ hostvars[host].ansible_user }}  ansible_password="{{ hostvars[host].ansible_password }}"
{%     endif %}
{%   endif %}
{% endfor %}

{% for group in groups %}
{%   if "gitlab" in group -%}
{%   elif "windows_domain_controllers" in group -%}
{%   elif "windows_instance1" in group -%}
{%   elif "windows_workstation" in group -%}
{%   elif "managed_nodes" in group -%}
{%   elif "rhel" in group -%}
{%   elif "docs" in group -%}
{%   elif "automation_hub" in group -%}
{%   elif "ungrouped" in group -%}
{%   else %}
[{{group}}]
{%   endif %}
{%   for entry in groups[group] %}
{%     for host in hostvars %}
{%       if entry == host and "student" + item + "-" in host %}
{%         if "windc" in host -%}
{%         elif "gitlab" in host -%}
{%         elif "docs" in host -%}
{%         else %}
{{ host|replace(ec2_name_prefix + "-", "") }}
{%         endif %}
{%       endif %}
{%     endfor %}
{%   endfor %}
{% endfor %}
